package com.louis.test.impl;

import com.louis.test.Calculator;

/**
 * @author XRY
 * @date 2023年06月27日8:52
 */
public class CalculatorStaticProxy implements Calculator {
    //被代理的目标对象传递过来
    private Calculator calculator;

    public CalculatorStaticProxy(Calculator calculator) {
        this.calculator = calculator;
    }

    @Override
    public int add(int i, int j) {
        System.out.println("[日志]add方法开始，参数是"+ i+" " + j);
        //调用目标对象的方法实现核心业务
        int result = calculator.add(i, j);
        System.out.println("[日志]add方法结束，结果是：" + result);
        return result;
    }

    @Override
    public int minus(int i, int j) {
        System.out.println("[日志]minus 方法开始，参数是"+ i+" " + j);
        int result = calculator.minus(i, j);
        System.out.println("[日志]minus 方法结束，结果是：" + result);
        return result;
    }

    @Override
    public int multiply(int i, int j) {
        System.out.println("[日志]multiply 方法开始，参数是"+ i+" " + j);
        int result = calculator.multiply(i,j);
        System.out.println("[日志]multiply 方法结束，结果是：" + result);
        return result;
    }

    @Override
    public int div(int i, int j) {
        System.out.println("[日志]div 方法开始，参数是"+ i+" " + j);
        int result = calculator.div(i, j);
        System.out.println("[日志]div 方法结束，结果是：" + result);
        return result;
    }
}
